package com.link2room.blaster.MNSworker;

import com.aliyun.mns.model.Message;
import com.link2room.blaster.facade.ISendTemplateMsgFacadeService;
import com.link2room.common.mns.Worker;
import com.link2room.common.util.JacksonUtil;
import com.link2room.blaster.dto.innerUse.MsgSendParamDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 预定成功消息推送
 * Created by LN on 2016/11/8.
 */
@Component("msgSendWroker")
public class MsgSendWroker implements Worker {
    private static Logger logger = LoggerFactory.getLogger(MsgSendWroker.class);
    @Resource
    private ISendTemplateMsgFacadeService sendWxTemplateMsgFacadeService;
    @Override
    public boolean exec(Message message) throws Exception {
        try{
            String msgbody = message.getMessageBody();
            logger.debug("正在处理线程Tread:"+Thread.currentThread().getName()+" 的msgBody : \n"+ msgbody);
            MsgSendParamDto msgSendParamDto = JacksonUtil.jsonToBean(msgbody, MsgSendParamDto.class);
            sendWxTemplateMsgFacadeService.sendHandler(msgSendParamDto);
           /* if(MsgConstant.CHANNEL.WECHAT.equals(dto.getChannel())){

            }*/
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return true;
        }
    }
}
